package com.goods.mq;

import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * 消费者
 * mq 接收消息
 * @RocketMQMessageListener 监听消息注解
 * consumerGroup 消费者组
 * topic 主题
 * MessageModel.CLUSTERING   集群模式---负载均衡--发送一条消息只有一个服务会收到
 * MessageModel.BROADCASTING 广播模式---发送一条消息所有服务都会收到
 */
@Component
@RocketMQMessageListener(consumerGroup = "springcloud-group",topic = "xb-topic", messageModel = MessageModel.CLUSTERING)
public class AcceptMessage implements RocketMQListener<String> {


    @Override
    public void onMessage(String message) {
        System.out.println(message);
    }
}
